package org.gw.ylc.authorization;

import org.gw.ylc.base.data.PermissionContext;
import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

@ComponentScan
@SpringBootApplication
public class AuthorizationConfiguration {
	public static void main(String[] args) {
		ConfigurableApplicationContext context = AuthorizationConfiguration.run(args);
		String port = context.getEnvironment().getProperty("server.port","8080");
		System.out.println("访问  http://localhost:"+port+"/ylc-base/dist/index.html#!/app/auth" +"\t来进行授权");
	}

	public static ConfigurableApplicationContext run(String[] args) {
		return new SpringApplicationBuilder().web(true).sources(AuthorizationConfiguration.class)
				.bannerMode(Banner.Mode.OFF).run(args);
	}

	@Bean
	public PermissionContext permissionContext() {
		return new PermissionContext();
	}

	@Bean
	public ContextInterceptor loginInterceptor() {
		return new ContextInterceptor();
	}

}
